package com.bw.medical.controller;

import java.util.*;
import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bw.medical.entity.DockerLevelEntity;
import com.bw.medical.vo.DiagnoseVo;
import com.bw.medical.vo.DoctorSumVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bw.medical.entity.DiagnoseEntity;
import com.bw.medical.service.DiagnoseService;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.R;



/**
 * 诊断表 
 *
 * @author wj
 * @email sunlightcs@gmail.com
 * @date 2021-08-22 21:39:10
 */
@RestController
@RequestMapping("medical/tbdiagnose")
public class DiagnoseController {
    @Autowired
    private DiagnoseService diagnoseService;

    /**
     * 患者诊断记录列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        IPage<DiagnoseEntity> page = diagnoseService.getLists(params);
        PageUtils pageUtils = new PageUtils(page.getRecords(), (int) page.getTotal(), (int) page.getSize(), (int) page.getPages());
        return R.ok().put("page", pageUtils);
    }
    /**
     * 该医生当天 下的患者诊断记录列表
     */
    @RequestMapping("/sLists")
    public R lists(@RequestParam Map<String, Object> params){
        IPage<DiagnoseEntity> page = diagnoseService.sLists(params);
        PageUtils pageUtils = new PageUtils(page.getRecords(), (int) page.getTotal(), (int) page.getSize(), (int) page.getPages());
        return R.ok().put("page", pageUtils);
    }
    //查看该医生诊断记录总和
    @RequestMapping("plist")
    public R plist(@RequestParam Map<String, Object> params){
        IPage<DoctorSumVo> page=diagnoseService.getPlist(params);
        PageUtils pageUtils = new PageUtils(page.getRecords(), (int) page.getTotal(), (int) page.getSize(), (int) page.getPages());
        return R.ok().put("page", pageUtils);
    }
    /**
     * 该医生当天 下的患者诊断评论记录
     */
    @RequestMapping("/pingLi")
    public R pingLi(@RequestParam Map<String, Object> params){
        IPage<DiagnoseEntity> page = diagnoseService.pingLi(params);
        PageUtils pageUtils = new PageUtils(page.getRecords(), (int) page.getTotal(), (int) page.getSize(), (int) page.getPages());
        return R.ok().put("page", pageUtils);
    }
    /**
     * 查询单个患者信息
     */
    @RequestMapping("/info")
    public R info(@RequestParam("reportId") Integer reportId){
        DiagnoseVo info = diagnoseService.info(reportId);
        return R.ok().put("diagnose", info);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DiagnoseEntity diagnose){
		diagnoseService.save(diagnose);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DiagnoseEntity diagnose){
		diagnoseService.updateById(diagnose);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] reportIds){
		diagnoseService.removeByIds(Arrays.asList(reportIds));

        return R.ok();
    }

}
